#include "changepassworddialog.h"
#include "ui_changepassworddialog.h"
#include <QMessageBox>

ChangePasswordDialog::ChangePasswordDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ChangePasswordDialog)
{
    ui->setupUi(this);
    setWindowTitle("修改密码");
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    
    // 连接取消按钮的点击信号
    connect(ui->submitBtn, &QPushButton::clicked, this, &ChangePasswordDialog::onSubmitButtonClicked);
}

ChangePasswordDialog::~ChangePasswordDialog()
{
    delete ui;
}

void ChangePasswordDialog::onSubmitButtonClicked()
{
    QString oldPassword = ui->oldPwdEdit->text();
    QString newPassword = ui->newPwdEdit->text();

    if (oldPassword.isEmpty() || newPassword.isEmpty()) {
        QMessageBox::warning(this, "警告", "所有字段都不能为空！");
        return;
    }
    

    // 这里应该添加实际的修改密码逻辑
    QMessageBox::information(this, "提示", "密码修改成功！");
    accept(); // 关闭对话框并返回QDialog::Accepted
}

void ChangePasswordDialog::on_pushButton_cancel_clicked()
{
    reject(); // 关闭对话框并返回QDialog::Rejected
}
